<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Javascript image dropdown - By JSON data</title>
<link rel="stylesheet" href="css/sample.css" />
<script src="../../jquery.min.js"></script>

<!-- <msdropdown> -->
<link rel="stylesheet" type="text/css" href="../css/dd.css" />
<script src="../jquery.dd.min.js"></script>
<!-- </msdropdown> -->

</head>
<body>
<table width="100%" border="0" cellspacing="1" cellpadding="5" class="topmenu">
  <tr>
    <td colspan="2" class="top"><h1>Javascript image dropdown <span id="ver"></span> <a title="Download" href="http://www.marghoobsuleman.com/jquery-image-dropdown" class="small">Download</a></h1></td>
  </tr>
  <tr>
    <td width="25%"><select style="width:250px"  name="pages" id="pages">
      <option value="" selected="selected">Choose a sample page</option>
      <option value="index.html">Normal</option>
      <option value="byjson.html">By Json Data</option>
      <option value="multiple-skin.html">Multiple Skin</option>
      <option value="css-sprite.html">CSS Sprite</option>
      <option value="object-oriented-approach.html">Object Oriented Approach</option>
      <option value="object-oriented-approach-more.html">Object Oriented Approach - More</option>
      <option value="use-checkbox.html">Use Checkbox</option>
      <option value="mouse-events.html">Mouse Events</option>
      <option value="help.html">Documentation</option>
    </select></td>
    <td align="left"><a href="help.html">Documentation</a></td>
  </tr>
</table>
<form action="submitdata.php" method="post" enctype="multipart/form-data" name="frmdata">
<table width="100%" border="0" cellspacing="1" cellpadding="5" class="tblWhite">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td valign="top"><a href="javascript:void(0)" id="btn1">Click to create by json data</a></td>
  </tr>
  <tr>
    <td valign="top">
    <div id="byjson"></div>
	</td>
  </tr>
  <tr>
    <td valign="bottom">&nbsp;</td>
  </tr>
  <tr>
    <td valign="bottom"><input type="submit" value="Submit" /></td>
  </tr>
  <tr>
    <td valign="bottom">&nbsp;</td>
  </tr>
  <tr>
    <td valign="bottom">Source Code:</td>
  </tr>
  <tr>
    <td valign="top">
    
<code>
<pre>
&lt;script>
function createByJson() {
	var jsonData = [					
					{description:'Choos your payment gateway', value:'', text:'Payment Gateway'},					
					{image:'../images/msdropdown/icons/Amex-56.png', description:'My life. My card...', value:'amex', text:'Amex'},
					{image:'../images/msdropdown/icons/Discover-56.png', description:'It pays to Discover...', value:'Discover', text:'Discover'},
					{image:'../images/msdropdown/icons/Mastercard-56.png', title:'For everything else...', description:'For everything else...', value:'Mastercard', text:'Mastercard'},
					{image:'../images/msdropdown/icons/Cash-56.png', description:'Sorry not available...', value:'cash', text:'Cash on devlivery', disabled:true},
					{image:'../images/msdropdown/icons/Visa-56.png', description:'All you need...', value:'Visa', text:'Visa'},
					{image:'../images/msdropdown/icons/Paypal-56.png', description:'Pay and get paid...', value:'Paypal', text:'Paypal'}
					];
	var jsn = $("#byjson").msDropDown({byJson:{data:jsonData, name:'payments'}}).data("dd");
}
$("#btn1").on("click", createByJson);
&lt;/script>    
</pre>
</code>    
    </td>
  </tr>
  <tr>
    <td valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top">&nbsp;</td>
  </tr>
</table>
</form>
<p>&nbsp;</p>

<script>
function createByJson() {
	var jsonData = [					
					{description:'Choos your payment gateway', value:'', text:'Payment Gateway'},					
					{image:'../images/msdropdown/icons/Amex-56.png', description:'My life. My card...', value:'amex', text:'Amex'},
					{image:'../images/msdropdown/icons/Discover-56.png', description:'It pays to Discover...', value:'Discover', text:'Discover'},
					{image:'../images/msdropdown/icons/Mastercard-56.png', title:'For everything else...', description:'For everything else...', value:'Mastercard', text:'Mastercard'},
					{image:'../images/msdropdown/icons/Cash-56.png', description:'Sorry not available...', value:'cash', text:'Cash on devlivery', disabled:true},
					{image:'../images/msdropdown/icons/Visa-56.png', description:'All you need...', value:'Visa', text:'Visa'},
					{image:'../images/msdropdown/icons/Paypal-56.png', description:'Pay and get paid...', value:'Paypal', text:'Paypal'}
					];
	var jsn = $("#byjson").msDropDown({byJson:{data:jsonData, name:'payments'}}).data("dd");
}
$("#btn1").on("click", function() {
	createByJson();
	$(this).hide();
});

$(document).ready(function(e) {		
	//no use
	try {
		var pages = $("#pages").msDropdown({on:{change:function(data, ui) {
												var val = data.value;
												if(val!="")
													window.location = val;
											}}}).data("dd");

		var pagename = document.location.pathname.toString();
		pagename = pagename.split("/");
		pages.setIndexByValue(pagename[pagename.length-1]);
		$("#ver").html(msBeautify.version.msDropdown);
	} catch(e) {
		//console.log(e);	
	}
	
	$("#ver").html(msBeautify.version.msDropdown);
});
</script>

</body>
</html>
